package com.ecloud.client;

import com.ecloud.common.JsonResult;
import com.ecloud.trend.vo.TdbEnvironmentPresentVo;
import com.ecloud.trend.vo.TdbPresentVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author Squbi
 */
@FeignClient(name = "hbase-server")
public interface HbaseClient {

    /**
     * 表是否存在
     *
     * @param tableName 表名
     * @return boolean
     * @author Squbi
     * @date 2021/7/20 16:48
     */
    @GetMapping("/hbase/exist/{tableName}")
    JsonResult existTable(@PathVariable String tableName);

    /**
     * 上传到数据库
     *
     * @param rowKey   行键
     * @param dailyMap 数据集
     * @return {@link JsonResult}
     * @author Squbi
     * @date 2021/7/20 16:48
     */
    @PostMapping("/hbase/daily/{rowKey}")
    JsonResult postDaily(@RequestBody Map<String, String> dailyMap, @PathVariable("rowKey") String rowKey);

    /**
     * 从数据库获取
     *
     * @param rowKey 行键
     * @return TDBDailyHbaseTable
     * @author Squbi
     * @date 2021/7/20 16:48
     */
    @GetMapping("/hbase/daily/json/{rowKey}")
    JsonResult getDailyJson(@PathVariable String rowKey);

    /**
     * 从数据库获取
     *
     * @param rowKey 行键
     * @return TDBDailyHbaseTable
     * @author Squbi
     * @date 2021/7/20 16:48
     */
    @GetMapping("/hbase/daily/{rowKey}")
    JsonResult getDaily(@PathVariable String rowKey);

    /**
     * 删除表
     *
     * @param tableName 表名
     * @return JsonResult
     * @author Squbi
     * @date 2021/7/23 17:44
     */
    @DeleteMapping("/hbase/{tableName}")
    JsonResult deleteTable(@PathVariable String tableName);


    /**
     * 传入能量实时数据
     *
     * @param tdbPresentVos {@link TdbPresentVo}
     * @return JsonResult
     * @author Squbi
     * @date 2021/7/27 9:47
     */
    @PostMapping("/hbase/present/energy")
    JsonResult postEnergyPresent(@RequestBody List<TdbPresentVo> tdbPresentVos);

    /**
     * 获取所有能量实时数据
     *
     * @param buildingName 建筑名
     * @return `Map< String, List< TdbPresentVo>>` map 时间戳-当时所属建筑的所有数据
     * @author Squbi
     * @date 2021/7/27 9:47
     */
    @GetMapping("/hbase/present/energy/{buildingName}")
    JsonResult getEnergyAllPresent(@PathVariable String buildingName);

    /**
     * 获取指定时间戳能量实时数据
     *
     * @param keyTime      时间戳
     * @param buildingName 建筑名
     * @return `Map< String, List< TdbPresentVo>>` map 时间戳-当时所属建筑的所有数据
     * @author Squbi
     * @date 2021/7/27 9:47
     */
    @GetMapping("/hbase/present/energy/{buildingName}/{keyTime}")
    JsonResult getEnergyPresent(@PathVariable("buildingName") String buildingName, @PathVariable("keyTime") String keyTime);

    /**
     * 上传控制实时数据
     *
     * @param tdbPresentVos {@link TdbPresentVo}
     * @return JsonResult
     * @author Squbi
     * @date 2021/7/27 9:48
     */
    @PostMapping("/hbase/present/control")
    JsonResult postControlPresent(@RequestBody List<TdbPresentVo> tdbPresentVos);

    /**
     * 获取所有控制实时数据
     *
     * @param buildingName 建筑名
     * @return `Map< String, List< TdbPresentVo>>` map 时间戳-当时所属建筑的所有数据
     * @author Squbi
     * @date 2021/7/27 9:48
     */
    @GetMapping("/hbase/present/control/{buildingName}")
    JsonResult getControlAllPresent(@PathVariable String buildingName);

    /**
     * 获取指定时间戳的能量实时数据
     *
     * @param keyTime      时间戳
     * @param buildingName 建筑名
     * @return `Map< String, List< TdbPresentVo>>` map 时间戳-当时所属建筑的所有数据
     * @author Squbi
     * @date 2021/7/27 9:48
     */
    @GetMapping("/hbase/present/control/{buildingName}/{keyTime}")
    JsonResult getControlPresent(@PathVariable("buildingName") String buildingName, @PathVariable("keyTime") String keyTime);

    /**
     * 上传环境实时数据
     *
     * @param environmentVos {@link TdbEnvironmentPresentVo}
     * @return JsonResult
     * @author Squbi
     * @date 2021/7/27 11:00
     */
    @PostMapping("/hbase/present/environment")
    JsonResult postEnvironmentPresent(@RequestBody List<TdbEnvironmentPresentVo> environmentVos);

    /**
     * 获取指定时间戳的环境实时数据
     *
     * @param keyTime 时间戳
     * @return List < TdbEnvironmentPresentVo>
     * @author Squbi
     * @date 2021/7/27 11:00
     */
    @GetMapping("/hbase/present/environment/{keyTime}")
    JsonResult getEnvironmentPresent(@PathVariable String keyTime);
}
